----------------------------------------------------------------------------------------------------------------------------------
--[[

    

]]--
----------------------------------------------------------------------------------------------------------------------------------
local hutao_com_physical_power = Class(function(self, inst)
    self.inst = inst


    self.classified = nil

    self.blockers = {}
    self.blocker_remove_event_fn = function(blocker)
        self:RemoveBlocker(blocker)
    end

end)
------------------------------------------------------------------------------------------------------------------------------
--- classified
    function hutao_com_physical_power:AttachClassified(classified)
        self.classified = classified
        classified:ListenForEvent("physical_power_com_update",function()
            self.inst:PushEvent("hutao_com_physical_power_update")
        end)
        print("hutao_com_physical_power:AttachClassified")
    end
------------------------------------------------------------------------------------------------------------------------------
--
    function hutao_com_physical_power:SetCurrent(value)
        if self.classified then
            self.classified:SetPhysicalPower(value)
        end
    end
    function hutao_com_physical_power:GetCurrent()
        if self.classified then
            return self.classified:GetPhysicalPower()
        end
        return 0
    end
    function hutao_com_physical_power:SetMax(value)
        if self.classified then
            self.classified:SetPhysicalPowerMax(value)
        end
    end
    function hutao_com_physical_power:GetMax()
        if self.classified then
            return self.classified:GetPhysicalPowerMax()
        end
        return 1
    end
    function hutao_com_physical_power:SetRunning(value)
        if self.classified then
            self.classified:SetPhysicalPowerRunning(value)
        end
    end
    function hutao_com_physical_power:IsRunning()
        if self.classified then
            return self.classified:GetPhysicalPowerRunning()
        end
        return false
    end
------------------------------------------------------------------------------------------------------------------------------
--- 外部屏蔽器。客户端的。
    function hutao_com_physical_power:AddBlocker(blocker)
        if self.blockers[blocker] then
            return
        end
        self.blockers[blocker] = true
        blocker:ListenForEvent("onremove",self.blocker_remove_event_fn)
    end
    function hutao_com_physical_power:RemoveBlocker(blocker)
        if not self.blockers[blocker] then
            return
        end
        local new_table = {}
        for k,v in pairs(self.blockers) do
            if k ~= blocker then
                new_table[k] = v
            end
        end
        self.blockers = new_table
        blocker:RemoveEventCallback("onremove",self.blocker_remove_event_fn)
    end
    function hutao_com_physical_power:IsBlocking()
        for k, v in pairs(self.blockers) do
            if k and k:IsValid() and v then
                return true
            end
        end
        return false
    end
------------------------------------------------------------------------------------------------------------------------------
return hutao_com_physical_power







